#include "MoveableComponent.h"
#include "PositionalComponent.h"


MoveableComponent::MoveableComponent(void)
{
	test = NONE;

}


MoveableComponent::~MoveableComponent(void)
{

}

void MoveableComponent::initMe(GameComponent* parent)
{
	parent->setProperties(MOVEABLE);
	entity_position = ((PositionalComponent*)parent->getComponent(POSITIONED))->getPos();
	destination = entity_position;
}

void MoveableComponent::updateMe(GameComponent* parent)
{
	if(destination->getX() > entity_position->getX())
	{
		entity_position->setX(entity_position->getX() + 2.0f);
	}
	if(destination->getX() < entity_position->getX())
	{
		entity_position->setX(entity_position->getX() - 2.0f);
	}

	if(destination->getZ() > entity_position->getZ())
	{
		entity_position->setZ(entity_position->getZ() + 2.0f);
	}
	if(destination->getZ() < entity_position->getZ())
	{
		entity_position->setZ(entity_position->getZ() - 2.0f);
	}

	/*if(destination->getY() > entity_position->getY())
	{
		entity_position->setY(entity_position->getY() + 2.0f);
	}
	if(destination->getY() < entity_position->getY())
	{
		entity_position->setY(entity_position->getY() - 2.0f);
	}*/

	switch(test)
	{
	case NONE:
		break;
	case NORTH:
		entity_position->setZ(entity_position->getZ() - 1);
		break;
	case SOUTH:
		entity_position->setZ(entity_position->getZ() + 1);
		break;
	case EAST:
		entity_position->setX(entity_position->getX() + 1);
		break;
	case WEST:
		entity_position->setX(entity_position->getX()- 1);
		break;
	}

}


//debug
void MoveableComponent::setMove(alterPosition m)
{
	test = m;
}

